package com.one.common.location_service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.amap.api.location.AMapLocation;

/**
 * Author: zhulunjun
 * Email: zhulunjun@qq.com
 * CreateDate: 2019/5/24 16:44
 * Description：
 **/
public class LocationChangBroadcastReceiver extends BroadcastReceiver {
    public static final String RECEIVER_ACTION = "location_in_background";
    public static final String RECEIVER_DATA = "location_data";

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(RECEIVER_ACTION)) {
            AMapLocation location = (AMapLocation) intent.getParcelableExtra(RECEIVER_DATA);
            if (null != location) {
                String string =  System.currentTimeMillis() + ","+location.getLatitude() + "," + location.getLongitude();
                ServiceUtils.saveFile(string, "broadcastlocation.txt", true);

                Log.v("定位数据", "经度：" + location.getLongitude() + " 纬度：" + location.getLatitude());

            }
        }
    }
}
